package de.clapp.client.awards;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JTextField;

import de.clapp.panels.MyPanel;
import de.clapp.panels.MyTabbedPanel;

@SuppressWarnings("serial")
public class AwardPanel extends MyTabbedPanel
{
    private JList<String> awardListe;
    private JList<String> artikelListe;
    
    private JButton hinzufuegen;
    
    private JLabel nameLabel;
    private JLabel punkteLabel;
    private JLabel belohnungLabel;
    private JLabel punkteArtikelLabel;
    
    private JTextField name;
    private JTextField punkte;
    private JTextField belohnung;
    private JTextField punkteArtikel;
    
    private JCheckBox awardArtikel;
    
    private MyPanel border;
    private MyPanel awardEinzeln;
    private MyPanel awardBorder;
    private MyPanel artikel;
        
    public AwardPanel()
    {
        this.setLayout(new BorderLayout());
        
        border = new MyPanel();
        border.setLayout(new GridBagLayout());
        
        String[] testAward = {"Tequila-Killer", "Caipi-King", "Bloody Mary"};
        awardListe = new JList<String>(testAward);
        
        this.addComponent(border, awardListe, 0, 0, 1, 3, 1, 1);
        
        awardEinzeln = new MyPanel("Awarddetails");
        awardEinzeln.setLayout(new GridBagLayout());
        
        awardBorder = new MyPanel();
        awardBorder.setLayout(new BorderLayout());
        
        this.nameLabel = new JLabel("Name: ");
        this.addComponent(awardEinzeln, nameLabel, 0, 0, 1, 1, 1, 1);
        
        this.name = new JTextField();
        this.addComponent(awardEinzeln, name, 1, 0, 1, 1, 1, 1);
        
        this.punkteLabel = new JLabel("Punkte ");
        this.addComponent(awardEinzeln, punkteLabel, 0, 1, 1, 1, 1, 1);
        
        this.punkte = new JTextField();
        this.addComponent(awardEinzeln, punkte, 1, 1, 1, 1, 1, 1);
        
        this.belohnungLabel = new JLabel("Belohnung: ");
        this.addComponent(awardEinzeln, belohnungLabel, 0, 2, 1, 1, 1, 1);
        
        this.belohnung = new JTextField();
        this.addComponent(awardEinzeln, belohnung, 1, 2, 1, 1, 1, 1);
        
        artikel = new MyPanel("Artikel");
        artikel.setLayout(new GridBagLayout());
        
        String[] testArtikel = {"Bier", "Sekt", "Wein"};
        artikelListe = new JList<String>(testArtikel);
        
        this.addComponent(artikel, artikelListe, 0, 0, 1, 3, 1, 1);
        
        this.punkteArtikelLabel = new JLabel("Punkte: ");
        this.addComponent(artikel, punkteArtikelLabel, 1, 0, 1, 1, 1, 1);
        
        this.punkteArtikel = new JTextField();
        this.addComponent(artikel, punkteArtikel, 2, 0, 1, 1, 1, 1);
        
        this.awardArtikel = new JCheckBox("Awardteilnehmer");
        this.addComponent(artikel, awardArtikel, 1, 1, 2, 1, 1, 1);
        
        this.addComponent(awardEinzeln, artikel, 0, 3, 2, 3, 1, 1);
        
        awardBorder.add(awardEinzeln, BorderLayout.NORTH);
        
        this.addComponent(border, awardBorder, 1, 0, 1, 1, 1, 1);
        
        this.add(border, BorderLayout.CENTER);
        
        this.setVisible(true);
    }
    
    void addComponent(Container cont, Component c, int x, int y, int width, int height, double weightx, double weighty)
    {
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.fill = GridBagConstraints.BOTH;
            gbc.gridx = x; 
            gbc.gridy = y;
            gbc.gridwidth = width; 
            gbc.gridheight = height;
            gbc.weightx = weightx; 
            gbc.weighty = weighty;
            cont.add(c, gbc);
    }
}
